from locust import HttpLocust,TaskSet,task

class UserBehavior(TaskSet):
    def on_start(self):
        self.index = 0
        self.longinData = [["lm",'aaa'],['liuchuan','LiuC456'],
                           ['dy','DY123'],['wangwu','ww123'],['admin','admin123']]
    @task
    def login(self):
        data = {"username":self.longinData[self.index][0],
                "password":self.longinData[self.index][1],"verifycode":"0000"}
        res = self.client.post("/WoniuSales/user/login",
                               data,catch_response=True)
        if 'login-pass' in res.text:
            res.success()
        else:
            res.failure("Login Fail.")
        self.index = (self.iy88+1)%len(self.longinData)

class WebSite(HttpLocust):
    task_set = UserBehavior
    min_wait = 1000
    max_wait = 3000